import { requestClient } from '#/api/request';

// 查询赛事赛道分页信息
export async function getCompTrackPageApi(params: any) {
  return requestClient.get(`/match/get-comp-track-page`, { params });
}

// 创建赛事赛道信息
export async function createCompTrackApi(data: any) {
  return requestClient.post(`/match/create-comp-track`, data);
}

// 修改赛事赛道信息
export async function updateCompTrackApi(data: any) {
  return requestClient.patch(`/match/update-comp-track`, data);
}

// 保存草稿
export async function saveCompTrackDraftApi(data: any) {
  return requestClient.patch(`/match/save-comp-track-draft`, data);
}

// 查询考核规则
export async function getReviewDimensionPageApi(params: any) {
  return requestClient.get(`/match/query-review-dimension-page`, { params });
}

// 更新状态-评审维度/评委列表/发布状态
export async function updateCompTrackStatusApi(data: any) {
  return requestClient.patch(`/match/update-comp-track-status`, data);
}

// 删除草稿
export async function deleteCompTrackDraftApi(data: any) {
  return requestClient.post(`/match/delete-comp-track-draft`, data);
}

// 删除赛道
export async function deleteCompTrackApi(data: any) {
  return requestClient.delete(`match/delete-comp-track/${data.id}`);
}
// 赛题说明数据结构类型定义
export interface EduCompTrackDescription {
  id?: string;
  trackId: string;
  draftPageContent?: string;
  pageContent?: string;
  createTime?: string;
  updateTime?: string;
}

// API响应格式类型定义
export interface ApiResponse<T = any> {
  status: number;
  message: string;
  data: T;
  timestamp: string;
}

/**
 * 新增赛题说明信息
 * 真实接口：POST /match/create-comp-track-description
 */
export async function createTrackDescriptionApi(data: {
  trackId: string;
  draftPageContent?: string;
  pageContent?: string;
  draft: boolean;
}): Promise<ApiResponse<EduCompTrackDescription>> {
  return requestClient.post('/match/create-comp-track-description', data);
}

/**
 * 修改赛题说明信息
 * 真实接口：PATCH /match/update-comp-track-description
 */
export async function updateTrackDescriptionApi(data: {
  id: string;
  trackId?: string;
  draftPageContent?: string;
  pageContent?: string;
  draft: boolean;
}): Promise<ApiResponse<EduCompTrackDescription>> {
  return requestClient.patch('/match/update-comp-track-description', data);
}

/**
 * 删除赛题说明信息
 * 真实接口：PATCH /match/delete-comp-track-draft/{id}
 */
export async function deleteTrackDescriptionByIdApi(id: string): Promise<ApiResponse<any>> {
  return requestClient.delete(`/match/delete-track-description-draft/${id}`);
}

/**
 * 获取赛题说明信息
 * 真实接口：GET /match/get-comp-track-description/{trackId}
 */
export async function getTrackDescriptionApi(params: { trackId: string }): Promise<ApiResponse<EduCompTrackDescription & { lastEditId?: string }>> {
  return requestClient.get(`/match/get-comp-track-description/${params.trackId}`);
}
